<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="css/style1.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../js/jquery-3.3.1.min.js"></script>
</head>

<body>

	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="#">首页</a></li>
    <li><a href="#">查看</a></li>
    </ul>
    </div>
    
    <div class="formbody">
    
    <div class="formtitle"><span>基本信息</span></div>
    
    <ul class="forminfo">
    <li><label>文章标题</label><input name="atitle" value="${article.atitle }" type="text" class="dfinput" disabled="disabled"/></li>
    <li><label>作者</label><input name="uname" value="${article.user.uname }" type="text" class="dfinput" disabled="disabled"/></li>
    <li><label>是否审核</label><cite>
    	<input name="astatus" id="radio1" type="radio" value="1"  />是      &nbsp;&nbsp;&nbsp;&nbsp;
    	<input name="astatus" id="radio0" type="radio" value="0" />否
    </cite></li>
    <li><label>创建时间</label><input name="" type="text" class="dfinput" value="<fmt:formatDate value='${article.acreatetime }' pattern='yyyy-MM-dd HH:mm:ss'/>" disabled="disabled"/></li>
    <li><div style="border:dashed 1px;">${article.articledetail.addetail }</div></li>
    <li><label>&nbsp;</label><input id="submit" type="button" class="btn" value="确认保存"/></li>
    </ul>
    
    
    </div>
    <script>
    	$(function(){
    	    var astatus=${article.astatus}
    		if(astatus==true){
    			$("#radio1").attr('checked','checked');
    		}else{
    			$("#radio0").attr('checked','checked');
    		}
    		
    		$("#submit").click(function(){
    			var aid=${article.aid};
    			var astatus=$("input[type='radio']").prop("checked");
    			$.ajax({
	                url:"${pageContext.request.contextPath}/admin-upadteAstatus",
	                type:"post",
	                data:{'aid':aid,'astatus':astatus},
	                success:function(data){
	                   console.log(data);
	                   if(data=='success'){
                   			alert("保存成功!");
                   			window.location.href="admin-articleinfo";
	                   }else{
	                   		alert("失败咯~");
	                   }
	                },   
	                error:function(e){
	                    alert("错误！！");
	                }
	            });
    		});
    		
    		
    	});
    </script>
</body>
</html>
